﻿<UserControl x:Class="CapstoneProjectAEReader.GUIs.DictionaryGUI.NoteManagement"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="640">
    <UserControl.Resources >
        <DataTemplate x:Key="NoteTemplate">
            <TextBlock Text="{Binding NoteContent}"  />
        </DataTemplate>
        <ContextMenu x:Key="NoteDetailContextMenu">
            <MenuItem x:Name="gotoNoteDetail" Click="HandleNoteDtLvMouseDbClick"/>
            <MenuItem x:Name="updateNoteDetail" Click="HandleUpdateButton"/>
            <MenuItem x:Name="deleteNoteDetail" Click="HandleBtDeleteNoteDetail"/>
        </ContextMenu>
        <ContextMenu x:Key="NoteContextMenu">
            <MenuItem x:Name="noteCtDelete" Click="HandleBtDeleteNote"></MenuItem>
        </ContextMenu>
    </UserControl.Resources>
    <Grid Background="CornflowerBlue" x:Name="NoteManagementGrid" Height="Auto" Width="Auto">
        <DockPanel>
            <Label x:Name="lbNoteFormTitle" FontSize="20" Foreground="FloralWhite" Grid.ColumnSpan="2" Grid.Row="0" DockPanel.Dock="Top"/>
            <StackPanel Orientation="Horizontal" Background="LightSkyBlue" Margin="4" DockPanel.Dock="Top">
                <TextBox x:Name="txtSearch" Width="200" Margin="5"></TextBox>
                <Button x:Name="btSearch" Background="Transparent" HorizontalAlignment="Center" Margin="4,2,2,2" 
                                VerticalAlignment="Center" BorderThickness="0" Click="HandleBtSearch">
                    <Image Source="Image/noteSearch.png" Height="20" />
                </Button>
            </StackPanel>
            <Grid Margin="4,0,4,8" Height="Auto" Width="Auto">
                <Grid.Background>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="AliceBlue" Offset="0" />
                        <GradientStop Color="SkyBlue" Offset="1" />
                    </LinearGradientBrush>
                </Grid.Background>
                <DockPanel>
                    <Grid DockPanel.Dock="Bottom">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Horizontal" Grid.Column="0">
                            <Button Background="Transparent" BorderThickness="0" Margin="4">
                                <Grid/>
                            </Button>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                            <Button x:Name="btApply" Background="Transparent" BorderThickness="0" Margin="4" Click="HandleApplyButton">
                                <Grid>
                                    <Image Source="Image/Button.png" Height="24"/>
                                    <Label x:Name="lbApply" HorizontalAlignment="Center"/>
                                </Grid>
                            </Button>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
                            <Button x:Name="btDeleteNote" Background="Transparent" BorderThickness="0" Margin="4" Click="HandleBtDeleteNote">
                                <Grid>
                                    <Image Source="Image/Button.png" Height="24"/>
                                    <Label x:Name="lbDeleteNote" HorizontalAlignment="Center"/>
                                </Grid>
                            </Button>
                        </StackPanel>
                    </Grid>

                    <Grid DockPanel.Dock="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition Width="2*"/>
                        </Grid.ColumnDefinitions>
                        <DockPanel Margin="5" Grid.Column="0">
                            <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" DockPanel.Dock="Top">
                                <Label x:Name="lbNoteList"/>
                            </Border>

                            <ListView x:Name="NoteListView" Width="auto" Margin="0,6,0,2" Padding="2" ItemTemplate="{StaticResource NoteTemplate}" SelectionChanged="HandleSelectNote" ContextMenu="{StaticResource NoteContextMenu}">
                            </ListView>
                        </DockPanel>
                        <StackPanel VerticalAlignment="Center" Grid.Column="1">
                            <Button Background="Transparent" HorizontalAlignment="Center" Margin="4,2,2,2" 
                                        VerticalAlignment="Center" BorderThickness="0">
                                <Image Source="Image/Get.png" Height="20" />
                            </Button>
                            <Button Background="Transparent" HorizontalAlignment="Center" Margin="4,2,2,2" 
                                        VerticalAlignment="Center" BorderThickness="0">
                                <Image Source="Image/Set.png" Height="20" />
                            </Button>
                        </StackPanel>
                        
                        <Grid Margin="5" Grid.Column="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="0.6*"/>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="0.4*"/>
                            </Grid.RowDefinitions>
                            <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" Grid.Row="0">
                                <Label x:Name="lbNoteDetails"/>
                            </Border>

                            <ListView x:Name="NoteDetailListView" Grid.Row="1" Margin="1,6,-1,2" MouseDoubleClick="HandleNoteDtLvMouseDbClick" ContextMenu= "{StaticResource NoteDetailContextMenu}">
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="FontSize" Value="12" />
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.View>
                                    <GridView>
                                        <GridViewColumn Width="250" x:Name="columnEbookTitle">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Path=BookTitle , StringFormat='{}{0:C}'}" 
                                                               HorizontalAlignment="Left" FontWeight="SemiBold" Foreground="DarkRed"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </GridViewColumn>
                                        <GridViewColumn Width="150" x:Name="columnDate">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Date, StringFormat='{}{0:C}'}" 
                                                               HorizontalAlignment="Center" Foreground="DarkOrange" />
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </GridViewColumn>
                                        <GridViewColumn Width="600" x:Name="columnDescription">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Description, StringFormat='{}{0:C}'}" 
                                                               HorizontalAlignment="Left" Height="40" FontSize="12" Foreground="Black"
                                                               TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </GridViewColumn>
                                    </GridView>
                                </ListView.View>
                            </ListView>

                            <Grid Grid.Row="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Button x:Name="btEdit" Background="Transparent" BorderThickness="0" Margin="4" Grid.Column="0" HorizontalAlignment="Left" Click="HandleUpdateButton">
                                    <Grid>
                                        <Image Source="Image/Button.png" Height="24"/>
                                        <Label x:Name="lbEdit" HorizontalAlignment="Center"/>
                                    </Grid>
                                </Button>
                                <Button x:Name="btDelete" Background="Transparent" BorderThickness="0" Margin="4" Grid.Column="1" HorizontalAlignment="Right" Click="HandleBtDeleteNoteDetail">
                                    <Grid>
                                        <Image Source="Image/Button.png" Height="24"/>
                                        <Label x:Name="lbDelete" HorizontalAlignment="Center"/>
                                    </Grid>
                                </Button>
                            </Grid>

                            <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" Grid.Row="3">
                                <Label x:Name="lbNoteDetail"/>
                            </Border>
                            <Grid Background="White" Margin="0,6,0,2" Grid.Row="4">
                                <Border BorderThickness="2" CornerRadius="10">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="Gray" Opacity="0.7"/>
                                    </Border.BorderBrush>
                                    <DockPanel Margin="3">
                                        <Border BorderBrush="LightGray" BorderThickness="0,0,0,1" DockPanel.Dock="Top">
                                            <Grid>
                                                <TextBlock FontWeight="Bold" x:Name="txtNotedWord" Padding="3" Foreground="Green"/>
                                                <TextBlock FontWeight="SemiBold" x:Name="txtPageNo" Padding="3" HorizontalAlignment="Right" Foreground="LightCoral"/>
                                            </Grid>
                                        </Border>
                                        <Grid DockPanel.Dock="Top">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <Border BorderBrush="LightGray" BorderThickness="0,0,1,1" Grid.Column="0">
                                                <TextBlock FontWeight="SemiBold" x:Name="txtTitle" Padding="3" Foreground="DarkRed"/>
                                            </Border>
                                            <Border BorderBrush="LightGray" BorderThickness="0,0,0,1" Grid.Column="1">
                                                <TextBlock x:Name="txtDate" HorizontalAlignment="Right" Padding="3" Foreground="DarkOrange" />
                                            </Border>
                                        </Grid>
                                        <RichTextBox x:Name="txtDescription"  Padding="3" DockPanel.Dock="Top" VerticalScrollBarVisibility="Visible" />
                                    </DockPanel>
                                </Border>
                            </Grid>
                        </Grid>
                    </Grid>
                </DockPanel>
            </Grid>
        </DockPanel>
    </Grid>
</UserControl>
